<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<html>
<head>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--[if lt IE 9]>
<script type="text/javascript" src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
<script type="text/javascript" src="http://libs.useso.com/js/respond.js/1.4.2/respond.min.js"></script>
<script type="text/javascript" src="http://cdn.bootcss.com/css3pie/2.0beta1/PIE_IE678.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="../resources/css/H-ui.css" />
<link type="text/css" rel="stylesheet"
	href="../resources/css/H-ui.admin.css" />
<link type="text/css" rel="stylesheet"
	href="../resources/font/font-awesome.min.css" />
<!--[if IE 7]>
<link href="http://www.bootcss.com/p/font-awesome/assets/css/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
<title>Backend System</title>

</head>
<body>
	<nav class="Hui-breadcrumb">
		<i class="icon-home"></i> Backend System
	</nav>
	<div class="pd-20">
		<form:form modelAttribute="getReportDto">

			<form:hidden path="cnt" />
			<form:hidden path="pageno" />
			<div class="text-c">
				User Name：
				<form:input type="text" class="input-text" style="width: 250px"
					placeholder="input user name" path="user" />
				&nbsp;&nbsp; Status：
				<form:select class="input-text" path="status" items="${statusList }"
					itemLabel="value" itemValue="key">
				</form:select>

				<button type="button" class="btn btn-success btn-search" id=""
					name="">
					<i class="icon-search"></i> Search
				</button>

			</div>
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="r">Total：<strong>${cnt }</strong> Items
				</span>
			</div>

		</form:form>
		<table
			class="table table-border table-bordered table-hover table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th>User Name</th>
					<th>Event Type</th>
					<th>Event</th>
					<th>Addr</th>
					<th>Send To</th>
					<th>Send Time</th>
					<th>Event Status</th>
					<th>Operation</th>
				</tr>
			</thead>
			<tbody>

				<c:forEach items="${items }" var="item">
					<tr class="text-c">
						<td>${item.user }</td>
						<td><c:choose>
								<c:when test="${item.type == '1' }">
					Text
					</c:when>
								<c:when test="${item.type == '2' }">
					Video
					</c:when>
								<c:when test="${item.type == '3' }">
					Image
					</c:when>
								<c:when test="${item.type == '4' }">
					Tel
					</c:when>
								<c:otherwise>Other</c:otherwise>
							</c:choose></td>
						<td><c:choose>
								<c:when test="${item.type == '1' || item.type == '4'}">
					${item.content }
					</c:when>
								<c:otherwise>
									<a href="javascript:void(0);"
										onclick="getmedia('${item.id}', '${item.filename }')">${item.filename }</a>
								</c:otherwise>
							</c:choose></td>
						<td>${item.position }</td>
						<td>${item.touser }</td>
						<td><fmt:formatDate value="${item.createtime }"
								pattern="yyyy-MM-dd HH:mm:ss" /></td>
						<td class="user-status"><c:choose>
								<c:when test="${item.status == '0' }">
									<span class="label label-warning">Unhandled</span>
								</c:when>
								<c:otherwise>
									<span class="label label-success">Handled</span>
								</c:otherwise>
							</c:choose></td>
						<td class="f-14 user-manage"><c:if
								test="${item.status == '0' }">
								<a href="javascript:void(0);" onclick="verify('${item.id}')"
									class="label label-success">Handle</a>
							</c:if></td>
					</tr>
				</c:forEach>

			</tbody>
		</table>
		<div id="pageNav" class="pageNav"></div>
	</div>
	<script type="text/javascript" src="../resources/js/jquery.min.js"></script>
	<script type="text/javascript" src="../resources/layer/layer.min.js"></script>
	<script type="text/javascript" src="../resources/js/pagenav.cn.js"></script>
	<script type="text/javascript" src="../resources/js/H-ui.js"></script>
	<script type="text/javascript"
		src="../resources/plugin/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript"
		src="../resources/js/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="../resources/js/H-ui.admin.js"></script>
	<script type="text/javascript">
		window.onload = (function() {
			
			document.getElementsByTagName('form')[0].onkeydown = function(e){
			    var e = e || event;
			    var keyNum = e.which || e.keyCode;
			    if(keyNum == 13){
				    $(".btn-search").click();
			    }
			    return keyNum==13 ? false : true;
			};

			var pageTag = 0;

			// optional set
			pageNav.pre = "&lt;Prev";
			pageNav.next = "Next&gt;";
			// p,当前页码,pn,总页面
			pageNav.fn = function(p, pn) {
				$("#pageinfo").text("Current:" + p + " Total: " + pn);
				if (pageTag == 1) {
					window.location.href = "getreport?user="
							+ encodeURI(encodeURI($("#user").val()))
							+ "&status=" + $("#status").val() + "&pageno="
							+ (p - 1) + "&size=20";
				}
				pageTag++;
			};
			//重写分页状态,跳到第三页,总页33页
			pageNav.go(parseInt($("#pageno").val()) + 1, parseInt($("#cnt")
					.val() / 20) + 1);

			$(".btn-search").click(
					function() {
						window.location.href = "getreport?user="
								+ encodeURI(encodeURI($("#user").val()))
								+ "&status=" + $("#status").val();
					});
			
			$("#user").focus().select();
		});

		function getmedia(id, filename) {
			window.location.href = "../report/getmedia?id=" + id + "&filename="
					+ filename;
		}
		function verify(id) {
			window.location.href = "verify?id=" + id;
		}
	</script>
</body>
</html>